import { WeaSearchGroup,WeaSelect,WeaTools ,WeaErrorPage ,WeaFormItem} from 'ecCom';
import { WeaSwitch } from 'comsMobx';

class MonitorCondition extends React.Component{

    constructor(){
        super();
        this.formParams = {};
    }

    shouldComponentUpdate(){
        return true;
    }
    render(){
        let group = [];
        const {queryStore} = this.props;
        const { condition,form} = queryStore;
        /**常用查询条件 */
        const formParamsTemp = form.getFormParams();
        for(let param in formParamsTemp){
            this.formParams[param] = formParamsTemp[param];
        }
        form.isFormInit && condition.map((v,index) =>{
            let items = [];
            v.items.map(item => {
                items.push({
                    com:(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@ueq8f4@${item.domkey[0]}`}
                            label={`${item.label}`}
                            labelCol={{span: `${item.labelcol}`}}
                            wrapperCol={{span: `${item.fieldcol}`}}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@k22q5t@${item.domkey[0]}`} fieldConfig={item} form={form} formParams={this.formParams} onEnterSearch={this.onEnterSearch} />
                        </WeaFormItem>),
                    colSpan:1
                });
            });
            group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@ylwo4m@${index}`} needTigger={true} title={v.title} showGroup={v.defaultshow} items={items}/>);
            
        });
        
        return <div>{group}</div>;
    }

    onEnterSearch = () =>{
        const { onEnterSearch } = this.props;
        onEnterSearch();
    }
}

export default WeaTools.tryCatch(React, 
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@ufhvt0`} msg={ props.error ? props.error : getLabel(383324,' 对不起，该页面异常，请联系管理员 ')+'！'} />,
    {error: ""}
)(MonitorCondition);